package cn.lintcode;


import java.util.LinkedList;

/**
 * 同余定理
 * @author labvi
 * @version 1.0.0
 */
public class HashFunction {
    public static int  hashCode2(char[] key, int HASH_SIZE) {
        // write your code here
        long hashCode = 0;
        for (int i = 0; i < key.length ;i++ ){
            hashCode += key[i] * Math.pow(33,key.length - 1 - i);
        }
        return  (int)(hashCode % HASH_SIZE);
    }

    public static void main(String[] args) {
        System.out.println(hashCode2("abc".toCharArray(),10));
    }
}
